/*
 * @Author: szx
 * @Date: 2022-04-29 14:11:04
 * @LastEditTime: 2022-04-29 14:15:47
 * @Description:
 * @FilePath: \leetcode\100-199\120\120.js
 */
/**
 * @param {number[][]} triangle
 * @return {number}
 */
var minimumTotal = function (triangle) {
    const n = triangle.length;
    const dp = Array.from(triangle[n - 1]);
    for (let i = n - 2; i >= 0; i--) {
        for (let j = 0; j <= i; j++) {
            dp[j] = Math.min(dp[j], dp[j + 1]) + triangle[i][j];
        }
    }
    return dp[0];
};
